String.prototype.padStart
String.prototype.padEnd



// 实现一个padStart

String.prototype.mypadStart = function(len, str = '') {
    // if(typeof this !== 'string' || !len) {
    //     throw err
    // }

    let S = String(this)
    if(len <= S.length) {
        return S
    }

    let s = S
    let l = len - S.length

    let s1 = ''

    while(s1.length < l) {
        s1 += str
    }
    let s2 = s1.splice(0, l)    

    
    return s
}

let a = 'xxx'.mypadStart(5, 'a')
console.log(a);